package cn.itcast.user.web;

import cn.itcast.user.config.DateformatProperties;
import cn.itcast.user.pojo.User;
import cn.itcast.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

//@RefreshScope
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Value("${server.port}")
    int port;

//    @Value("${pattern.dateformat}")
//    String dateformat;
    @Autowired
    private DateformatProperties dateformatProperties;

    /**
     * 路径： /user/110
     *
     * @param id 用户id
     * @return 用户
     */
    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") Long id) {
        User user = userService.queryById(id);
        user.setId((long) port);
        return user;
    }

    @GetMapping("now")
    public Object now(){

        return dateformatProperties;
    }
}
